<template>
	<view>
		<!--  -->
		<view class="margin">
			<view class="points mt20 flex-cen">
				<view class="text-center">
					<view class="text-white">
						当前可使用积分
					</view>
					<view class="text-white " style="font-size: 72rpx;">
						{{count || 0}}
					</view>
				</view>
			</view>
			<view class=" mt10" style="color: #7976e9;">
				<p>*1积分=1人民币，可用于兑换商品等.</p>
				<p>
					积分可以通过签到获得
				</p>
			</view>
		</view>
		<view class="mt20 uni-text-gray flex-cen ms10">
			积分明细
		</view>
		<view class="bg-white">
			<!--  -->
			<u-cell-group v-if="list.length != 0">
				<u-cell v-for="(item,index) in list" :key="index" title="签到成功" :value="splice(item.xtCrdsCount)"
					:label="item.createTime" center></u-cell>
			</u-cell-group>
			<!--  -->
			<u-empty mode="list" v-else></u-empty>
		</view>
		<!-- <u-loadmore :status="status" /> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				status: 'loadmore',
				pageNum: 1,
				pageSize: 10,
				count: 0,
				list: []
			};
		},
		onShow() {
			this.getList()
			// this.balance()
		},
		methods: {
			splice(word) {
				return '+' + word
			},
			async getList(e) {
				let data = {
					"userId": uni.getStorageSync('userInfo').userid,
					"pageNum": this.pageNum,
					"pageSize": this.pageSize
				}
				let arr =[]
				let re = await this.$API.poitnsApi.getList(data);
				/*  */
				arr= re.list
				
				
				let total = arr.reduce((prev, item) => {
				  return prev + Number(item.xtCrdsCount);
				}, 0);
				
				this.count = total
				

				console.log(total, "total")

				this.list = re.list.reverse()
			},
			async balance(e) {
				let id = uni.getStorageSync('userInfo').userid
				let re = await this.$API.poitnsApi.balance(id);
				this.count = re
			},
		}

	}
</script>

<style lang="scss">
	page {
		background-color: #f3f3f3;
	}

	.points {
		// background-color: #55aaff;
		background-color: #7976e9;
		border-radius: 12rpx;
		height: 200rpx;
	}
	::v-deep .u-cell__title-text{
			font-size: 28rpx;
			    line-height: 50rpx;
	}
	::v-deep .u-cell__label{
			font-size: 28rpx;
	}
	::v-deep .u-cell__value{
		font-size: 28rpx;
	}
</style>